package com.example.administrator.myapplication.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.administrator.myapplication.R;
import com.example.administrator.myapplication.base.BaseMainActivity;
import com.example.administrator.myapplication.mode.UserInfo;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;
import me.nereo.multi_image_selector.MultiImageSelector;
import me.nereo.multi_image_selector.MultiImageSelectorActivity;

import static com.example.administrator.myapplication.view.HomeActivity.REQUEST_CODE;

/**
 * 说明：
 * 作者： 阳2012; 创建于： 2017/5/5 1:12
 */
public class MyActivity extends BaseMainActivity {
    public static String PICTUE;
    public static String NAME = "姓名";
    public static String NUM = "000";
    @BindView(R.id.picture)
    ImageView picture;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.number)
    TextView number;



    ArrayList<String> picturePath = new ArrayList<>();

    public static void startUI(Activity activity) {
        Intent intent = new Intent(activity, MyActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }


    @Override
    public int getContentView() {
        return R.layout.activity_my;
    }


    @Override
    public void initView() {
        super.initView();
        toolbar.setTitle("个人中心");


    }

    @Override
    public void parseIntent(Intent intent) {

    }

    @Override
    protected void onResume() {
        super.onResume();
        name.setText("帐号：" + UserInfo.userData.getAccount());
        number.setText("密码：" + UserInfo.userData.getPassword());
    }

    @Override
    public int currentItem() {
        return 3;
    }


    @OnClick({R.id.picture, R.id.name})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.picture:
                MultiImageSelector.create()
                        .showCamera(true)
                        .single()
                        .origin(picturePath)
                        .start(this, REQUEST_CODE);

                break;
            case R.id.name:


                break;
        }
    }



    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        //过程图片路径
        if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
            picturePath.clear();
            picturePath.addAll(data.getStringArrayListExtra(MultiImageSelectorActivity.EXTRA_RESULT));

            Glide
                    .with(this)
                    .load(picturePath.get(0))
                    .into(picture);

        }
    }

}
